package com.surendra.vendingmachine.unittest;

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class VendingMachineItemTest {
public VendingMachineItem item1, item2, item3, item4;
	@Before
	public void setUp() throws Exception {
		item1= new VendingMachineItem("Pepsi",1.50);
		item2= new VendingMachineItem("Coke",1.25);
		item3= new VendingMachineItem("Cracker",1.75);
		
	}

	@After
	public void tearDown() throws Exception {
		item1=null;
		item2=null;
		item3=null;
		
	}

	@Test
	/**
	 * tests instance of VendingMachineItem
	 */
	public void getString_MatchesValuePassedToConstructor() {
		
		String name="bar";
		Double money=1.50;
		VendingMachineItem item= new VendingMachineItem(name, money);
		assertEquals(name, item.getName());
		assertEquals(money, item.getPrice(),0.001);
		
		
	}@Test(expected=VendingMachineException.class)
	/**
	 * 
	 */public void VendingMachineItemLessThanZeroAmountExceptionTest(){
		
		item4= new VendingMachineItem("Busch",-9.00);
		
	}
	/*@Test
	/**
	 * tests the whether name passed is same
	 */
public void getNameTest(){
	String s="Pepsi";
	Double d=1.90;
	VendingMachineItem expected= new VendingMachineItem(s,d);
		assertEquals(s, expected.getName());
		assertEquals("Pepsi", s);
}
}